package recognizer;

public class CharacterData {
	private String[] chars;
	private double[] probs;
	
	public CharacterData(String[] chars, double[] probabilities) {
		this.chars=chars;
		this.probs=probabilities;
	}
	
	public static CharacterData combine(CharacterData c1, CharacterData c2){
		String[] chars=new String[c1.chars.length*c2.chars.length];
		double[] probs=new double[chars.length];
		int z=0;
		for(int i=0;i<c1.chars.length;i++)for(int j=0;j<c2.chars.length;j++){
			chars[z]=c1.chars[i]+c2.chars[j];
			probs[z]=c1.probs[i]*c2.probs[j];
			z++;
		}
		return new CharacterData(chars, probs);
	}
	
	public double getStringProbability(int index){
		return probs[index];
	}
	
	public int getSize(){
		return chars.length;
	}
	
	public String getStringAt(int index){
		return chars[index];
	}

	public double getStringProbability(String pw) {
		for(int i=0;i<chars.length;i++)if(chars[i].equals(pw))return probs[i];
		return 0;
	}
}
